package com.pn.service.impl;

import com.pn.entity.Result;
import com.pn.mapper.BuyListMapper;
import com.pn.model.BuyList;
import com.pn.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PurchaseServiceImpl implements PurchaseService {

    @Autowired
    private BuyListMapper buyListMapper;

    /**
     * 添加采购单
     * @param buyList
     * @return
     */
    @Override
    public Result savePurchase(BuyList buyList) {

        //补充字段--给fact_buy_num字段实际采购数量赋值buy_num字段的值
        buyList.setFactBuyNum(buyList.getBuyNum());

        //添加采购单
        int i = buyListMapper.insertPurchase(buyList);
        if(i>0){
            return Result.ok("采购单添加成功！");
        }

        return Result.err(Result.CODE_ERR_BUSINESS,"采购单添加失败！");
    }
}
